package com.fanhang.samples.queue;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

public class QueueSizeTest {

	public static void main(String[] args) throws InterruptedException {
		// add()和remove()方法在失败的时候会抛出异常(不推荐)
		ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<>(3);
		System.out.println(queue.offer("a"));
		System.out.println(Arrays.deepToString(queue.toArray()));
		
		queue.offer("b");
		System.out.println(Arrays.deepToString(queue.toArray()));
		queue.offer("c");
		System.out.println(Arrays.deepToString(queue.toArray()));
		
		queue.poll();
		System.out.println(Arrays.deepToString(queue.toArray()));
		
		queue.offer("d");
		System.out.println(Arrays.deepToString(queue.toArray()));
		queue.offer("e", 10, TimeUnit.SECONDS);
		System.out.println(Arrays.deepToString(queue.toArray()));
	}

}
